package com.hifar.sso;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;

/**
 * SSO独立运行应用
 * 专门用于测试SSO模块功能
 *
 * @author system
 * @since 1.0.0
 */
@SpringBootApplication(exclude = {
    DataSourceAutoConfiguration.class,
    HibernateJpaAutoConfiguration.class,
    SecurityAutoConfiguration.class
})
@ComponentScan(basePackages = {"com.hifar"})
public class SSOStandaloneApplication {

    public static void main(String[] args) {
        try {
            System.out.println("=== SSO独立应用启动 ===");
            System.out.println("端口: 8082");
            System.out.println("测试地址: http://localhost:8082/sso/test/health");
            System.out.println("登录页面: http://localhost:8082/sso/login?client_id=test&response_type=code&redirect_uri=http://localhost:8080/callback");
            System.out.println("========================");

            // 禁用DevTools重启
            System.setProperty("spring.devtools.restart.enabled", "false");
            System.setProperty("spring.devtools.livereload.enabled", "false");

            SpringApplication app = new SpringApplication(SSOStandaloneApplication.class);
            app.setAdditionalProfiles("sso");
            app.run(args);

        } catch (Exception e) {
            System.err.println("SSO应用启动失败:");
            e.printStackTrace();
            System.exit(1);
        }
    }
}
